<template>

  <lay-container fluid="true" class="fly-container">
    <lay-card v-auth="['product:clazz:info:query']" class="fly-search-card">
      <lay-form :model="queryProductClazzInfoParams" size="sm" ref="refResetQueryProductClazzInfo">
        <lay-form-item label="标题名称" prop="clazzTitle" mode="inline">
          <lay-input v-model="queryProductClazzInfoParams.clazzTitle"></lay-input>
        </lay-form-item>
        <lay-form-item label="是否展示/有效标志: Y-有效;N-无效" prop="validFlag" mode="inline">
          <lay-input v-model="queryProductClazzInfoParams.validFlag"></lay-input>
        </lay-form-item>
        <lay-form-item mode="inline">
          <lay-button class="fly-button fly-button-search" size="sm"
                      @click=" reloadProductClazzInfoDate(1, flyLayPage.limit) ">
            <lay-icon class="layui-icon-search"></lay-icon>
            查询
          </lay-button>
          <lay-button class="fly-button fly-button-reset" size="sm" @click=" resetQueryProductClazzInfo ">
            <lay-icon class="layui-icon-refresh"></lay-icon>
            重置
          </lay-button>
          <lay-button v-auth="['product:clazz:info:exp']" size="sm" class="fly-button fly-button-exp" @click="">
            <lay-icon class="layui-icon-export"></lay-icon>
            导出
          </lay-button>
        </lay-form-item>
      </lay-form>

    </lay-card>


    <!-- table   :default-toolbar="true"  :height="'100%'" line row nob -->
    <div class="table-box">
      <lay-table :page="false" :skin="'line'" :height="'90%'"
                 :columns=" productClazzInfoColumns "
                 :loading=" tableProductClazzInfoData.loading "
                 :data-source=" tableProductClazzInfoData.rows "
                 @change=" reloadProductClazzInfoDate ">

        <template v-slot:toolbar>
          <lay-button v-auth="['product:clazz:info:save']" size="sm" class="fly-button fly-toolbar-addition"
                      @click=" onTapProductClazzInfoAdd ">
            <lay-icon class="layui-icon-addition"></lay-icon>
            新增
          </lay-button>
        </template>

        <template v-slot:operator="{ row }">
          <lay-button v-auth="['product:clazz:info:view']" size="sm" class="fly-button fly-view-button"
                      @click=" onTapProductClazzInfoView(row) ">
            <lay-icon class="layui-icon-list"></lay-icon>
            查看
          </lay-button>
          <lay-button v-auth="['product:clazz:info:update']" size="sm" class="fly-button fly-edit-button"
                      @click=" onTapProductClazzInfoEdit(row) ">
            <lay-icon class="layui-icon-edit"></lay-icon>
            编辑
          </lay-button>

          <lay-button v-auth="['product:clazz:info:delete']" size="sm" class="fly-button fly-remove-button"
                      @click=" removeProductClazzInfoHandler(row.id) ">
            <lay-icon class="layui-icon-delete"></lay-icon>
            删除
          </lay-button>

        </template>
      </lay-table>


      <lay-page v-model="flyLayPage.page"
                v-model:limit="flyLayPage.limit"
                :layout="flyLayPage.layout"
                :pages="flyLayPage.pages"
                :limits="flyLayPage.limits"
                theme="blue"
                :total=" tableProductClazzInfoData.total"
                @change="previousNextPage" style="margin-top: 15px"></lay-page>

    </div>
  </lay-container>


  <RefProductClazzInfo ref="refProductClazzInfoComponent"/>

</template>


<script setup lang="ts" name="productClazzInfoComponent">
import {ref, reactive, onMounted} from 'vue';
import RefProductClazzInfo from './RefProductClazzInfo.vue';

import useProductClazzInfoComposable from '@/composables/product/ProductClazzInfoComposable';

const {
  refProductClazzInfoComponent,
  refResetQueryProductClazzInfo,
  resetQueryProductClazzInfo,
  productClazzInfo,
  flyLayPage,
  tableProductClazzInfoData,
  productClazzInfoColumns,
  queryProductClazzInfoParams,

  /* 加载表格 */
  reloadProductClazzInfoDate,
  loadTableProductClazzInfoData,

  /* 新增, 编辑, 查看按钮 */
  onTapProductClazzInfoAdd,
  onTapProductClazzInfoEdit,
  onTapProductClazzInfoView,

  /* 接口 */
  removeProductClazzInfoHandler,
  productClazzInfoDataHandler
} = useProductClazzInfoComposable();


/**
 * 上一页, 下一页
 * @param current
 * @param limit
 */
const previousNextPage = ({current = 1, limit = 10}) => {
  queryProductClazzInfoParams.page = current;
  queryProductClazzInfoParams.limit = limit;
  loadTableProductClazzInfoData(queryProductClazzInfoParams);
}


/**
 * 页面初始化, 加载数据
 */
onMounted(() => {
  reloadProductClazzInfoDate(1, flyLayPage.limit);
})


</script>


<style scoped>

</style>